﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;

using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Spreadsheets;

namespace DataSources.Holder
{
    public class GoogleSpreadsheets : DataSources.GoogleSpreadsheets, IDataHolder
    {
        public event EventHandler EntryChanged;

        public GoogleSpreadsheets(string login, string password) :
            base(login, password)
        {
        }

        public IDataHolder GetChildDataSource(string entryHash)
        {
            if (this.spreadsheets.Contains(entryHash))
                return new GoogleWorksheets(this.service, this, entryHash);
            return null;
        }

        public Size GetSize()
        {
            return Size.Empty;
        }

        public Hashtable GetEntries()
        {
            return spreadsheets;
        }

        public void Submit(string entryHash, object inputData)
        {
            // useless
        }

        public void Request(string entryHash)
        {
            // TODO: implement - when new aspects were added on server.
            //OnEntryChanged(EventArgs.Empty);
        }

        protected virtual void OnEntryChanged(EventArgs e)
        {
            EventHandler handler = this.EntryChanged;
            if (handler != null)
            {
                handler(this, e);
            }
        }
    }
}
